/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package minesweeper;

import java.awt.GridLayout;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import util.GameSettings;
import util.GameUtility;

/**
 *
 * @author CodeBlue
 */
// create panel that store the map
public class GenPanel extends JPanel {

    public static List<MyButton> buttonList;

    public GenPanel() {
        int rows = GameSettings.NUM_OF_ROWS;
        int cols = GameSettings.NUM_OF_COLS;
        setLayout(new GridLayout(rows, cols));
        buttonList = new ArrayList<MyButton>();
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                MyButton myButton = new MyButton("");
                myButton.setPoint(new Point(i, j));
                buttonList.add(myButton);
            }
        }
        GameUtility.getInstance().generateMap(buttonList, rows * cols);
        for (MyButton button : buttonList) {
            button.setColor();
            add(button);
        }
        GameUtility.flagCount = 0;
    }
}
